$def with (msg, error)

$#
$# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for
$# more information about the licensing of this file.
$#

$var title: $:_("My profile")

$var Column: $:template_helper.call('preferences_menu',current='profile')

$def NavbarF():
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a href="$get_homepath()/preferences" title="$:_('Preferences')" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-gears"></i></a>
            </li>
            <li class="breadcrumb-item active"><a href="#"><i class="fa fa-user"></i> $:_("My profile") <span class="sr-only">$:_("(current)")</span></a></li>
        </ol>
    </nav>
$var Navbar: $:NavbarF()

<h2>$:_("My profile")</h2>

$if error:
    <div class="alert alert-danger alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        $:msg
    </div>
$elif msg:
    <div class="alert alert-success alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        $:msg
    </div>

$if not user_manager.session_username():
    <div class="alert alert-warning alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        $:_("Please set a new username")
    </div>

<form method="post">
    <div class="row">
        <div class="col-sm-12">
            <label class="control-label">$:_("Username :") </label>
            <input name="username" type="text" class="form-control" value="$user_manager.session_username()" $('disabled' if user_manager.session_username() else '')>
        </div>
        <div class="col-sm-12">
            <label class="control-label">$:_("Complete name :") </label>
            <input name="realname" type="text" class="form-control" value="$user_manager.session_realname()">
        </div>
        <div class="col-sm-12">
            <label class="control-label">$:_("Email address :") </label>
            <input name="email" type="text" class="form-control" value="$user_manager.session_email()" disabled>
        </div>
        <div class="col-sm-12">
            <label class="control-label">$:_("Language :") </label>
            <select name="language" class="form-control">
                $for code, language in available_languages.items():
                <option value="$code" $('selected' if code == user_manager.session_language() else '')>$language</option>
            </select>
        </div>
        $if allow_registration:
            <div class="col-sm-12">
                <label class="control-label">$:_("Old password :") </label>
                <input name="oldpasswd" type="password" class="form-control">
            </div>
            <div class="col-sm-6">
                <label class="control-label">$:_("New password (min. 6 characters) :") </label>
                <input name="passwd" type="password" class="form-control">
            </div>
            <div class="col-sm-6">
                <label class="control-label">$:_("Confirm new password :") </label>
                <input name="passwd2" type="password" class="form-control">
            </div>
        <div class="col-sm-12"><br />
            <button type="submit" name="save" class="btn btn-primary btn-block"><i class="fa fa-save"></i> $:_("Save my profile")</button>
        </div>
    </div>
</form>